﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="KMrpt8.aspx.cs" Inherits="KMrpt8" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>采购订单查询</title>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            height: 28px;
            background: #E7EBEF url(./images/header.png) repeat-x 0 0;
        }
    </style>
    <script>
        var template = '<span style="color:{0};">{1}</span>';

        var change = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value);
        };

        var pctChange = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
        };
        //导出EXCEL
        var exportData = function (format) {
            App.FormatType.setValue(format);
            var store = App.GridPanel1.store;
            store.submitData(null, { isUpload: true });
        };
        var doSort = function () {
            App.Store1.sort(getSorters());
        };

        var getSorters = function () {
            var sorters = [];

            Ext.each(App.Toolbar2.query('button'), function (button) {
                sorters.push(button.sortData);
            }, this);

            return sorters;
        };

        var changeSortDirection = function (button, changeDirection) {
            var sortData = button.sortData,
                iconCls = button.iconCls;

            if (sortData) {
                if (changeDirection !== false) {
                    button.sortData.direction = Ext.String.toggle(button.sortData.direction, "ASC", "DESC");
                    button.setIconCls(Ext.String.toggle(iconCls, "icon-sortascending", "icon-sortdescending"));
                }
                App.Store1.clearFilter();
                doSort();
            }
        };

        var createItem = function (data) {
            var header = data.header,
                headerCt = header.ownerCt,
                reorderer = headerCt.reorderer;

            // Hide the drop indicators of the standard HeaderDropZone
            // in case user had a pending valid drop in 
            if (reorderer) {
                reorderer.dropZone.invalidateDrop();
            }
            return createSorterButtonConfig({
                text: header.text,
                sortData: {
                    property: header.dataIndex,
                    direction: "s"
                }
            });
        };

        var createSorterButtonConfig = function (config) {
            config = config || {};

            Ext.applyIf(config, {
                listeners: {
                    click: function (button, e) {
                        changeSortDirection(button, true);
                    }
                },
                iconCls: config.sortData.direction.toLowerCase() == "asc" ? "icon-sortascending" : "icon-sortdescending",
                reorderable: true,
                xtype: 'splitbutton',
                menu: {
                    xtype: "menu",
                    items: [
                        {
                            text: "移除",
                            handler: remove
                        }
                    ]
                }
            });

            return config;
        };

        var canDrop = function (dragSource, event, data) {
            var sorters = getSorters(),
                header = data.header,
                length = sorters.length,
                entryIndex = this.calculateEntryIndex(event),
                targetItem = this.toolbar.getComponent(entryIndex),
                i;

            // Group columns have no dataIndex and therefore cannot be sorted
            // If target isn't reorderable it could not be replaced
            if (!header.dataIndex || (targetItem && targetItem.reorderable === false)) {
                return false;
            }

            for (i = 0; i < length; i++) {
                if (sorters[i].property == header.dataIndex) {
                    return false;
                }
            }

            return true;
        };

        var remove = function (menu) {
            App.Toolbar2.remove(menu.up('button'));
            App.Store1.clearFilter();
            doSort();
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:Hidden ID="FormatType" runat="server" />
                <ext:GridPanel ID="GridPanel1" runat="server" TitleAlign="Center">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server" Layout="Container">
                            <Items>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:DateField runat="server" ID="txtbdate" FieldLabel="开单日期" />
                                        <ext:Label runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txtedate" />
                                        <ext:MultiCombo ID="txtstatus" runat="server" SelectionMode="All" FieldLabel="单据状态"
                                            DisplayField="statename" ValueField="stateid">
                                            <Store>
                                                <ext:Store ID="Store2" runat="server">
                                                    <Model>
                                                        <ext:Model ID="Model2" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="stateid" />
                                                                <ext:ModelField Name="statename" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:MultiCombo>
                                        <ext:MultiCombo runat="server" ID="txtseason" FieldLabel="季节" DisplayField="seasonname"
                                            ValueField="seasonname">
                                            <Store>
                                                <ext:Store runat="server" ID="Store4">
                                                    <Model>
                                                        <ext:Model ID="Model4" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="seasonname" />
                                                                <ext:ModelField Name="seasonname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:Button ID="Button1" runat="server" Text="查询" OnDirectClick="BtnQureyUser" UI="Info"
                                            Icon="Find">
                                            <DirectEvents>
                                                <Click>
                                                    <EventMask ShowMask="true" Msg="加载中...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:DateField runat="server" ID="txtbjhdate" FieldLabel="交货日期" />
                                        <ext:Label ID="Label2" runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txtejhdate" />
                                        <ext:ComboBox runat="server" ID="txtvendor" FieldLabel="供应商" DisplayField="vendcustname"
                                            ValueField="vendcustid">
                                            <Store>
                                                <ext:Store runat="server">
                                                    <Model>
                                                        <ext:Model runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="vendcustid" />
                                                                <ext:ModelField Name="vendcustname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                            </Items>
                                        </ext:ComboBox>
                                        <ext:MultiCombo runat="server" ID="txtyear" FieldLabel="年份" DisplayField="yearno"
                                            ValueField="yearno">
                                            <Store>
                                                <ext:Store runat="server" ID="Store3">
                                                    <Model>
                                                        <ext:Model ID="Model3" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="yearno" />
                                                                <ext:ModelField Name="yearno" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar>
                                    <Items>
                                        <ext:DateField runat="server" ID="txtsrkdate" FieldLabel="入库日期" />
                                        <ext:Label ID="Label3" runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txterkdate" />
                                        <ext:MultiCombo runat="server" ID="txtmatkind" FieldLabel="类别" DisplayField="kindname"
                                            ValueField="kindname">
                                            <Store>
                                                <ext:Store runat="server" ID="Store5">
                                                    <Model>
                                                        <ext:Model ID="Model5" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="kindname" />
                                                                <ext:ModelField Name="kindname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:TextField runat="server" ID="txtmatname" FieldLabel="货品简称" />
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar>
                                    <Items>
                                        <ext:DateField runat="server" ID="txtsdhdate" FieldLabel="到货日期" />
                                        <ext:Label ID="Label4" runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txtedhdate" />
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar ID="Toolbar2" runat="server">
                                    <Items>
                                        <ext:ToolbarTextItem ID="ToolbarTextItem1" runat="server" Text="排序区域:" Reorderable="false" />
                                        <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" Reorderable="false" />
                                    </Items>
                                    <Plugins>
                                        <ext:BoxReorderer ID="BoxReorderer1" runat="server">
                                            <Listeners>
                                                <Drop Handler="changeSortDirection(dragCmp, false);" />
                                            </Listeners>
                                        </ext:BoxReorderer>
                                        <ext:ToolbarDroppable ID="ToolbarDroppable1" runat="server">
                                            <CreateItem Fn="createItem" />
                                            <CanDrop Fn="canDrop" />
                                            <Listeners>
                                                <Drop Fn="doSort" />
                                            </Listeners>
                                        </ext:ToolbarDroppable>
                                    </Plugins>
                                </ext:Toolbar>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store ID="Store1" runat="server" PageSize="100" OnReadData="RefreshDataSet"
                            OnSubmitData="Store1_Submit">
                            <Model>
                                <ext:Model ID="Model1" runat="server">
                                    <Fields>
                                        <ext:ModelField Name="订单号" ServerMapping="billno" Type="String" />
                                        <ext:ModelField Name="订单单据类型" ServerMapping="billtypename" Type="String" />
                                        <ext:ModelField Name="单据状态" ServerMapping="cnstatename" Type="String" />
                                        <ext:ModelField Name="开单日期" ServerMapping="billdate" Type="String" />
                                        <ext:ModelField Name="交货日期" ServerMapping="STARTSHIPDATE" Type="String" />
                                        <ext:ModelField Name="生效日期" ServerMapping="CHECKDATE" Type="String" />
                                        <ext:ModelField Name="供应商编号" ServerMapping="vendcustcode" Type="String" />
                                        <ext:ModelField Name="供应商" ServerMapping="vendcustname" Type="String" />
                                        <ext:ModelField Name="颜色" ServerMapping="colorname" Type="String" />
                                        <ext:ModelField Name="季节" ServerMapping="seasonname" Type="String" />
                                        <ext:ModelField Name="系列" ServerMapping="seriesname" Type="String" />
                                        <ext:ModelField Name="类别" ServerMapping="kindname" Type="String" />
                                        <ext:ModelField Name="货品ID" ServerMapping="MaterialID" Type="String" />
                                        <ext:ModelField Name="货号" ServerMapping="MaterialCode" Type="String" />
                                        <ext:ModelField Name="简称" ServerMapping="MaterialShortName" Type="String" />
                                        <ext:ModelField Name="吊牌价" ServerMapping="PRORETAILPRICE" Type="String" />
                                        <ext:ModelField Name="订单数量" ServerMapping="qty" Type="Float" />
                                        <ext:ModelField Name="订单零售金额" ServerMapping="retailamt" Type="Float" />
                                        <ext:ModelField Name="订单结算价" ServerMapping="BALAPRICE" Type="Float" />
                                        <ext:ModelField Name="总到货量" ServerMapping="RECEIPTQTY" Type="Float" />
                                        <ext:ModelField Name="总入库量" ServerMapping="STOCKQTY" Type="Float" />
                                        <ext:ModelField Name="订单取消数量" ServerMapping="CancelQty" Type="Float" />
                                        <ext:ModelField Name="结算数量" ServerMapping="BALAQTY" Type="Float" />
                                        <ext:ModelField Name="第一次入库日期" ServerMapping="friDate" Type="String" />
                                        <ext:ModelField Name="第一次入库数量" ServerMapping="friInQty" Type="Float" />
                                        <ext:ModelField Name="第二次入库日期" ServerMapping="secdDate" Type="String" />
                                        <ext:ModelField Name="第二次入库数量" ServerMapping="secdInQty" Type="Float" />
                                        <ext:ModelField Name="第三次入库日期" ServerMapping="lastDate" Type="String" />
                                        <ext:ModelField Name="第三次入库数量" ServerMapping="lastInQty" Type="Float" />
                                        <ext:ModelField Name="第一次到货日期" ServerMapping="friRecDate" Type="String" />
                                        <ext:ModelField Name="第一次到货数量" ServerMapping="frirecQty" Type="Float" />
                                        <ext:ModelField Name="第二次到货日期" ServerMapping="secdrecDate" Type="String" />
                                        <ext:ModelField Name="第二次到货数量" ServerMapping="secdrecQty" Type="Float" />
                                        <ext:ModelField Name="第三次到货日期" ServerMapping="lastRecDate" Type="String" />
                                        <ext:ModelField Name="第三次到货数量" ServerMapping="lastrecQty" Type="Float" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                                <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="100" />
                                        <ext:ListItem Text="200" />
                                        <ext:ListItem Text="500" />
                                        <ext:ListItem Text="1000" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="100" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                    </Listeners>
                                </ext:ComboBox>
                                <ext:Button ID="Button2" runat="server" Text="导出Excel" Icon="PageExcel">
                                    <Listeners>
                                        <Click Handler="exportData('xls');" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                            <Plugins>
                                <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
                    <Listeners>
                        <AfterLayout Handler="#{ToolbarDroppable1}.addDDGroup(this.child('headercontainer').reorderer.dragZone.ddGroup); doSort();"
                            Single="true" />
                    </Listeners>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
